<?php

session_start();
$_SESSION['user']=$_POST['username'];


$user=$_SESSION['user'];
$pass=$_POST['password'];
$email=$_POST['email'];

//set the values neccessary to connect to the database
$host="localhost";
$username="root";
$password="";
$db="assessmentdb";

//create the connection to the database
$connection=mysql_connect($host, $username, $password);

//select my database
$mysel=mysql_select_db($db);

$username=mysql_real_escape_string($user);
$password=mysql_real_escape_string($pass);
$emailaddress=mysql_real_escape_string($email);

$check= "select username from user where username = \"$username\"";
$result=mysql_query($check, $connection);
$numofrows=mysql_num_rows($result);
if ($numofrows == 1)
{
echo "Username already exist choose another one";
header("location:register.php");
}
else{
$insert="insert into user values(\"$username\",\"$password\",\"$email\")"; 
mysql_query($insert, $connection); 
echo "You Have Successfuly Registered";
header("location:entry.php");
}



?>